package openase.audio;

import openase.audio.AudioFingerprint;

public class AudioFingerprint {

	private AudioInfo source;
	private int offset;
	private long hash;

	AudioFingerprint(int offset, long hash) {
		this(null, offset, hash);
	}

	AudioFingerprint(AudioInfo source, int offset, long hash) {
		this.source = source;
		this.offset = offset;
		this.hash = hash;
	}

	void setSource(AudioInfo source) {
		this.source = source;
	}

	public AudioInfo getSource() {
		return source;
	}

	public int getOffset() {
		return offset;
	}

	public long getHash() {
		return hash;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (hash ^ (hash >>> 32));
		result = prime * result + offset;
		result = prime * result + ((source == null) ? 0 : source.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		AudioFingerprint other = (AudioFingerprint) obj;
		if (hash != other.hash)
			return false;
		if (offset != other.offset)
			return false;
		if (source == null) {
			if (other.source != null)
				return false;
		} else if (!source.equals(other.source))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "AudioFingerprint [source=" + source + ", offset=" + offset + ", hash=" + hash + "]";
	}

}
